//
//  BiPurchaseIndexViewController.m
//  TrunkIndustryManageSystem
//
//  Created by WT_lyy on 15/4/25.
//  Copyright (c) 2015年 李璐西. All rights reserved.
//

#import "BiPurchaseIndexViewController.h"
#import "BiPurchaseListViewController.h"
@interface BiPurchaseIndexViewController ()

@end

@implementation BiPurchaseIndexViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSDictionary * imageDic = [NSDictionary dictionaryWithObjectsAndKeys:@"common/icon_liebiao",@"ordercheck",
                               @"common/icon_liebiao",@"refitonline",
                               @"common/icon_liebiao",@"vrifystorage",nil];
    
    
    NSDictionary * titleDic = [NSDictionary dictionaryWithObjectsAndKeys:@"订单审批",@"ordercheck",
                               @"改装上线",@"refitonline",
                               @"验车入库",@"vrifystorage",nil];
    
    
    
    NSMutableArray * imagearr = [NSMutableArray array];
    NSMutableArray * titlearr = [NSMutableArray array];
    NSArray * saleArr = [BiUserEntity sharedInstance].permissionDic[@"zhengchecaigou"];
    
    for (int i =0 ; i < saleArr.count; i++) {
        NSString * purchaseStr = saleArr[i];
        
        [imagearr addObject:imageDic[purchaseStr]];
        
        [titlearr addObject:titleDic[purchaseStr]];
    }
    
    
    [self refreshTable:titlearr imageArr:imagearr title:@"整车采购"];
    
    
}

#pragma -mark UitabeViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    UITableViewCell * cell  = [tableView cellForRowAtIndexPath:indexPath];
    
    UILabel * tltlelab = (UILabel *)[cell viewWithTag:2];
    
    NSLog(@"%@",tltlelab);
    
    BiPurchaseListViewController  * viewCtrl = [[BiPurchaseListViewController alloc] init];
    
    if (tltlelab.text.hash == @"订单审批".hash) {
        
        viewCtrl.type = 0;
    }
    else if (tltlelab.text.hash == @"改装上线".hash) {
        
        viewCtrl.type = 1;
    }
    else if (tltlelab.text.hash == @"验车入库".hash) {
        
        viewCtrl.type = 2;
    }

    [self.navigationController pushViewController:viewCtrl animated:YES];
    
}

@end
